import {
  createRouter,
  createWebHistory
} from 'vue-router'
import HomeView from '../views/HomeView.vue'
const router = createRouter({
  history: createWebHistory(
    import.meta.env.BASE_URL),
  routes: [{
      path: '/myTabbar',
      name: 'myTabbar',
      component: () => import('../views/myTabbar.vue'),
      redirect: '/',
      children: [{
          path: '/',
          name: 'home',
          component: HomeView
        }, {
          path: '/about',
          name: 'about',
          component: () => import('../views/AboutView.vue')
        },
        {
          path: '/myClass',
          name: 'myClass',
          component: () => import('../views/myClass.vue')
        },
        {
          path: '/miaoWu',
          name: 'miaoWu',
          component: () => import('../views/miaoWu.vue')
        },
        {
          path: '/tool',
          name: 'tool',
          component: () => import('../views/tool.vue')
        },
        {
          path: '/my',
          name: 'my',
          component: () => import('../views/my.vue')
        },
      ],
    }, {
      path: '/detail',
      name: 'detail',
      component: () => import('../views/detail.vue')
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/login.vue')
    },
    // 设置
    {
      path: '/set',
      name: 'set',
      component: () => import('../views/set.vue')
    },
    //我的订单
    {
      path: '/myOrder',
      name: 'myOrder',
      component: () => import('../views/myOrder.vue')
    },
    //兑换课程
    {
      path: '/myCourse',
      name: 'myCourse',
      component: () => import('../views/myCourse.vue')
    },
    //地址管理
    {
      path: '/myLocation',
      name: 'myLocation',
      component: () => import('../views/myLocation.vue')
    },
    //收藏
    {
      path: '/myCollect',
      name: 'myCollect',
      component: () => import('../views/myCollect.vue')
    },
    //我的会员
    {
      path: '/myVip',
      name: 'myVip',
      component: () => import('../views/myVip.vue')
    },
    //我优惠券
    {
      path: '/myYhq',
      name: 'myYhq',
      component: () => import('../views/myYhq.vue')
    },
    //  我的 消息通知
    {
      path: '/myMessage',
      name: 'myMessage',
      component: () => import('../views/myMessage.vue')
    },
    //  我的 问题反馈
    {
      path: '/myMatter',
      name: 'myMatter',
      component: () => import('../views/myMatter.vue')
    },
    // 课程表
    {
      path: '/timetable',
      name: 'timetable',
      component: () => import('../views/timetable.vue')
    }
  ]

})



router.beforeEach((to, form) => {
  if (localStorage.getItem('666')) {
    // console.log(1);
    return true;
  } else {
    console.log(2);
    // return 'home'
    console.log(to);
    to.fullPath = '/'
  }
})
export default router